package com.yingside.gui;

import javax.swing.*;
import java.awt.*;

public class TestPaintFrame extends JFrame {
    public TestPaintFrame() {
        this.setTitle("鼠标事件窗口");
        this.setBounds(300, 300, 400, 400);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

    //paint不需要我们调用，java虚拟机会自动的调用paint方法
    public void paint(Graphics g) {
        super.paint(g);
        //设置画笔颜色
        g.setColor(Color.RED);
        //画一个椭圆
        g.fillOval(50,50,40,40);
        g.fillOval(100,100,40,40);
        g.fillOval(200,50,40,40);

        g.setColor(new Color(100,100,100));

        g.fillRect(300,100,50,50);

        g.drawLine(30,30,30,300);
        g.drawLine(60,30,60,300);
        g.drawLine(90,30,90,300);
    }

    public static void main(String[] args) {
        TestPaintFrame testPaintFrame = new TestPaintFrame();
        testPaintFrame.setVisible(true);

    }
}
